package model;

/**
 * @Create Harlantown
 * @Description
 * @create 2022-12-27 下午 5:55
 */
public class MemoryBlock {
    // 内存块编号
    private int physicalNumber;
    // 最后访问时间
    private long visitTime;
    // 是否可以修改（是否正在被进程占用）
    private boolean canChange;
    // 具体内容
    private ContentBlock contentBlock;
    // 下一块地址（链表形式）
    private MemoryBlock nextBlock;

    public boolean isCanChange() {
        return canChange;
    }

    public void setCanChange(boolean canChange) {
        this.canChange = canChange;
    }

    public int getPhysicalNumber() {
        return physicalNumber;
    }

    public void setPhysicalNumber(int physicalNumber) {
        this.physicalNumber = physicalNumber;
    }

    public long getVisitTime() {
        return visitTime;
    }

    public void setVisitTime(long visitTime) {
        this.visitTime = visitTime;
    }

    public ContentBlock getContentBlock() {
        return contentBlock;
    }

    public void setContentBlock(ContentBlock contentBlock) {
        this.contentBlock = contentBlock;
    }

    public MemoryBlock getNextBlock() {
        return nextBlock;
    }

    public void setNextBlock(MemoryBlock nextBlock) {
        this.nextBlock = nextBlock;
    }

    public void addToMemoryBlock(DiskBlock block) {
        this.setContentBlock(new ContentBlock(40, block.getContentP()));
        this.setVisitTime(System.currentTimeMillis());
        this.setCanChange(false);
    }

    public void refreshVisitTime(){
        this.setVisitTime(System.currentTimeMillis());
    }

}
